class TestCase:
    def __init__(self, cid, module, title, priority, condition, step, expected, actual, bug_id):
        self.cid = cid
        self.module = module
        self.title = title
        self.priority = priority
        self.condition = condition
        self.step = step
        self.expected = expected
        self.actual = actual
        self.bug_id = bug_id


class Bug:
    def __init__(self, bid, description, status):
        self.bid = bid
        self.description = description
        self.status = status

    def __str__(self):
        return f"{self.bid},{self.description},{self.status}"


class BugManager:

    def __init__(self):
        self.bugs = []

    def list_bugs(self):
        bug_list = []
        for bug in self.bugs:
            bug_list.append(str(bug))
        return bug_list

    def add_bug(self, bug):
        self.bugs.append(bug)

    def get_bug(self, bid):
        for bug in self.bugs:
            if bug.bid == bid:
                return bug
        return "没有找到该bug"

    def update_bug(self, bid, bug):
        for i in range(len(self.bugs)):
            if self.bugs[i].bid == bid:
                self.bugs[i] = bug
                return "bug更新成功"
            return "没有找到该bug"

    def delete_bug(self, bid):
        for i in range(len(self.bugs)):
            if self.bugs[i].bid == bid:
                del self.bugs[i]
                return f"bug删除成功"
        return f"没有找到该bug"


class TestcaseManager:
    def __init__(self, bug_manager):
        self.testcases = []
        self.bug_manager = bug_manager

    def list_testcases(self):
        testcase_list = []
        for t in self.testcases:
            testcase_list.append(str(t))
        return testcase_list

    def add_testcase(self, testcase):
        self.testcases.append(testcase)

    def get_testcase(self, cid):
        for testcase in self.testcases:
            if testcase.cid == cid:
                return testcase
        return "没找到该测试用例"

    def update_testcase(self, cid, testcase):
        pass

    def search_testcases(self, module=None, priority=None, bug_id=None):
        pass


if __name__ == '__main__':
    bug_manager = BugManager()
    testcase_manager = TestcaseManager(bug_manager)
    bug_manager.add_bug(Bug(bid='1', description="login", status='新建'))
    print(bug_manager.list_bugs())
    testcase_manager.add_testcase(
        TestCase(cid='1', module='增加', title='bug测试', priority=1, condition='无', step="无", expected='成功',
                 actual='成功', bug_id='1'))
    print(testcase_manager.list_testcases())
    print(testcase_manager.get_testcase('1'))
